﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace ETask.Client.Converters
{
    public class PriorityToBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return Brushes.Gray;

            if (Enum.TryParse<Priority>(value.ToString(), out var priority))
            {
                switch (priority)
                {
                    case Priority.High:
                        return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFE74C3C"));
                    case Priority.Medium:
                        return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFD9644"));
                    case Priority.Low:
                        return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA5B1C2"));
                    default:
                        return Brushes.Gray;
                }
            }

            return Brushes.Gray;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public enum Priority
    {
        Low,
        Medium,
        High
    }
}
